import { Injectable } from '@nestjs/common';
import { CreateGuradDto } from './dto/create-gurad.dto';
import { UpdateGuradDto } from './dto/update-gurad.dto';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository, Like } from 'typeorm';
import { Guard } from './entities/gurad.entity';

@Injectable()
export class GuradService {
  constructor(
    @InjectRepository(Guard)
    private guard: Repository<Guard>,
  ) {}
  create(createGuradDto: CreateGuradDto) {
    return 'This action adds a new gurad';
  }

  async findAll(query: { keyWord: string }) {
    console.log(query.keyWord);
    const data = await this.guard.create({ name: '张三', mybase: '123456' });
    const result = await this.guard.insert(data);
    console.log('data', data);
    console.log('result', result);
    return data;
  }

  findOne(id: number) {
    return `This action returns a #${id} gurad`;
  }

  update(id: number, updateGuradDto: UpdateGuradDto) {
    return `This action updates a #${id} gurad`;
  }

  remove(id: number) {
    return `This action removes a #${id} gurad`;
  }
}
